package model.conversor;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.ParseException;
import java.util.Locale;

public class Conversor {

	public static double converterMoeda(String valor) throws ParseException{
		DecimalFormat format = new DecimalFormat("#,##0.00");
		return format.parse(valor).doubleValue();
	}
	
	public static String converterMoeda(Double valor) throws ParseException{
		DecimalFormat format = new DecimalFormat ("#,##0.00", new DecimalFormatSymbols (new Locale ("pt", "BR")));
		String s = format.format(valor);
		String s1 = "";
		for (int i = 0; i < s.length(); i++){
			if ((s.charAt(i) != '.') && (s.charAt(i) != ','))
				s1 += s.charAt(i);
		}
		return s1; 
	}
	
}
